<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf8">
    <title>test</title>
  </head>
  <body>
	  <h1>it works!</h1>
    <iframe id="iframe" src="iframe.html"></iframe>
    <script type="text/javascript">
      var gui = require('nw.gui');
      var port = gui.App.argv[0]||13013;
      var result = 'fail';
      var local_window_flag = false;
      var win = gui.Window.get();
      win.eval(null,"local_window_flag = true;");
      var iframe = document.getElementById('iframe');
      iframe.onload = function(){
        win.eval(iframe,"iframe_window_flag = true;")
        setTimeout(function(){
          var iframe_window_flag = iframe.contentWindow.iframe_window_flag;
          if (local_window_flag && iframe_window_flag){
            result = 'success';
          }

    var socket = require('net').connect({port: 13013});
    socket.setEncoding('utf8');
    socket.end(result);

        },1000)
      };
    </script>
  </body>
</html>
    
